google.load('visualization', '1', {packages:['table']});

function drawPlayerTable(playerTableResp0) 
{
    var playerTableResp = eval('(' + playerTableResp0.responseText + ')'); 
	var data = new google.visualization.DataTable();
	data.addColumn('string', 'Asset');
	data.addColumn('number', 'Your View (%)');
	data.addColumn('number', 'No of Assets');
    data.addColumn('number', 'Market Price (c$)');
	data.addColumn('number', 'Value (c$)');
	data.addRows(playerTableResp.assetsList.length);
	for (var i = 0; i < playerTableResp.assetsList.length; i++)
	{
		data.setCell(i, 0, playerTableResp.assetsList[i].name );
		data.setCell(i, 1, playerTableResp.assetsList[i].playerView);
		data.setCell(i, 2, playerTableResp.assetsList[i].quantity);
        data.setCell(i, 3, playerTableResp.assetsList[i].marketPrice);
		data.setCell(i, 4, playerTableResp.assetsList[i].value);
	}

	var table = new google.visualization.Table(document.getElementById('playerTable_div'));	
	table.draw(data, {width: 450, height: 200, title: 'Player Data'});
}

var updatePlayerTable = function() 
{
    var args = { type:"get", url:"/json/getPlayerMainViewQty/", complete:drawPlayerTable };
    $.ajax(args);
    return false;
};

$(document).ready( function() 
{
    updatePlayerTable();
});
    
